<script setup>
import {ElMessage} from "element-plus";
import {Avatar, Edit, Promotion, Star, Tickets} from "@element-plus/icons-vue";

// 按钮事件设为首页
function setHome() {
  console.log("Home");
  // 设为首页的代码
  const url = window.location.href;
  try {
    obj.style.behavior = 'url(#default#homepage)';
    obj.setHomePage(url);
  } catch (e) {
    if (window.netscape) {
      try {
        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
      } catch (e) {
        ElMessage(
            "抱歉，此操作被浏览器拒绝！");
      }
    } else {
      ElMessage("抱歉，您所使用的浏览器无法完成此操作");
    }
  }
}

// 按钮事件设为收藏
function topCase() {
  console.log("Case");
  // 加入收藏的代码
  if (window.sidebar && window.sidebar.addPanel) { // Firefox <23
    window.sidebar.addPanel(document.title, window.location.href, '');
  } else if ((window.sidebar && /Firefox/i.test(navigator.userAgent)) || (window.opera && window.print)) { // Firefox 23+ and Opera <= 14
    ElMessage("抱歉，您所使用Firefox的浏览器无法完成此操作");
  } else if (window.external && ('AddFavorite' in window.external)) { // IE Favorites
    window.external.AddFavorite(location.href, document.title);
  } else if (window.opera && window.print) { // Opera >= 10.50 (Android)
    ElMessage("抱歉，您所使用Opera的浏览器无法完成此操作");
  } else if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1 && window.chrome) { // Chrome, newer versions of Opera (Desktop)
    ElMessage("抱歉，您所使用Chrome的浏览器无法完成此操作");
  } else { // Other browsers
    ElMessage('请手动添加此网页到书签');
  }
}

</script>

<template>
  <div class="line">
    <el-row class="taper-line">
      <el-col :span="12" style="text-align: left; ">
        <el-icon class="ioc">
          <Edit/>
        </el-icon>
        <a @click="setHome">将本站设为首页</a>
        |
        <el-icon class="ioc">
          <Star/>
        </el-icon>
        <a @click="topCase">收藏本站</a>
      </el-col>
      <el-col :span="12" style="text-align: right">
        <el-icon class="ioc">
          <Promotion/>
        </el-icon>
        <!-- 路由切换 <a href="/login">登录 </a> 可以用 <router-link to="/login">登录</router-link> -->
        <router-link to="/contactUs">联系我们</router-link>
        |
        <el-icon class="ioc">
          <Avatar/>
        </el-icon>
        <router-link to="/LoginAndRegistration/login">登录</router-link>
        |
        <el-icon class="ioc">
          <Tickets/>
        </el-icon>
        <router-link to="/LoginAndRegistration/registration">免费注册</router-link>
      </el-col>
    </el-row>
    <el-row class="Header-log">
      <a href="/" target="balnk">
        <img src="@/assets/img/LogosTelegram.svg" style="width: 30px;" alt/>
      </a>
      <div>吉吉图书馆</div>
    </el-row>
  </div>
</template>

<style scoped>
.line {
  --ioc-txt-color: #f18888;
  --txt-color: #e4d091;
  --txt-margin: 0 5px;
}

.Header-log {
  margin-top: 15px;
  margin-left: 15px;
  font-size: 26px;
  color: var(--txt-color);

}

.ioc {
  color: var(--ioc-txt-color);
  font-size: 20px;
}

.taper-line {

  /*鼠标光标*/
  /* cursor: pointer;*/
  color: var(--ioc-txt-color);
  margin: var(--txt-margin);

  margin-top: 5px;
  /* text-decoration: underline; */
}

a {
  /*鼠标光标*/
  cursor: pointer;
  color: var(--ioc-txt-color);
  margin: var(--txt-margin);
  text-decoration: none;
}
</style>
